<?php
header("Access-Control-Allow-Origin","*");
session_start();
    $username = $_POST['username'];
    $password = $_POST['password'];
    
    if(!preg_match("/^[a-zA-Z0-9]{4,10}$/",$username)){
        echo "9998";
    }
    else if(!preg_match("/^[a-zA-Z0-9]{6,10}$/",$password)){
        echo "9999";
    }
    else{
            require './userBiao.php';
            
            $aa = new userBiao();

            $str = "select name from user where name = '$username'";
            $res1 = $aa->getOne($str);
            
            if($res1){
                echo "10002";
            }
            else{

                $result = $aa->insert(["name"=>"$username","password"=>"$password"]); 
                if($result){
                    $sql = "SELECT NAME,PASSWORD from `user` WHERE `name`= '$username' AND `password`= '$password'";
            
                    $result1 = $aa->getone($sql);
                    
                    if($result1){
                        echo $aa->getJSON('10001',$result1);
                    }
                }
            }
    }

            
    
